import axios from 'axios';

console.log('环境', process.env.NODE_ENV)
// development开发 test测试  production生产
let env = 'production';
let baseUrl = '';
if (env === 'development') {
  baseUrl = '待配置';
} else if (env === 'test') {
  baseUrl = '待配置';
} else if (env === 'production') {
  baseUrl = 'http://huruqing.cn:3002/api';
}


const get = (url, data) => {
  url = baseUrl + url;
  return new Promise((resolve, reject) => {
    axios.get(url, {
      params: data
    }).then(res => {
      if (res.data.code == 666) {
        resolve(res.data);
      } else {
        reject(res.data.msg);
      }
    }).catch(error => {
      reject('网络异常,请稍后再试');
    })
  })
}

export default {
  get
}